package maple.core.contextproviders;

import maple.core.ContextProvider;
import maple.lang.Language;
import maple.util.Context;

public class SimpleHumanPresence extends ContextProvider
{
	public SimpleHumanPresence()
	{
		super( 0 );

		// from Consumer
		_preconditions.add( Context.Type.MOTIONLEVEL.toString() ); 
		_postcondition = Context.Type.HUMANPRESENCE.toString();
	}

	protected String interpret()
	{
		String[] motion_levels = _perceptions.get( _preconditions.get( 0 ) ).split( Language.COMMA );
	
		if( motion_levels.length == 0 )
		{
			return ContextProvider.State.UNKNOWN.toString();
		}
		else
		{
			for( String motion_level : motion_levels )
			{
				if( motion_level.equals( Context.MotionLevel.HIGH.toString() ) )
				{
					return Context.HumanPresence.TRUE.toString();
				}
			}
		}
		return Context.HumanPresence.FALSE.toString();
	}
}
